<?php

class Default_Model_DbTable_Category extends Zend_Db_Table_Abstract
{

    protected $_name = 'categories';

    public function getAllCat(){
    	return $this->fetchAll();
    }
    
    public function getCatByParent($parent){
    	$select = $this->select()
    	->from($this->_name)
    	->where("parent = $parent");
    	return $this->fetchAll($select);    	
    }
    
    public function getCatByLang($lang){
    	if($lang == "vi"){
    		$select = $this->select()
    		->from($this->_name,array("cat_id","cat_name","parent","vi as lang"))
    		->where("stt = 0")
    		->order("parent");
    	}else{
    		$select = $this->select()
    		->from($this->_name,array("cat_id","cat_name","parent","en as lang"))
    		->where("stt = 0")
    		->order("parent");
    	}
    	return $this->fetchAll($select);
    }

}

